/**
 * Copyright (c) 2009 blurredVision
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
 * associated documentation files (the "Software"), to deal in the Software without restriction, 
 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 
 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or 
 * substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT 
 * NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT 
 * OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
#ifndef __GUI_BUTTON_H__
#define __GUI_BUTTON_H__

#pragma once

#include "Label.h"
#include "IHighlightable.h"
#include "ITextureAtlasUser.h"
#include <string>

namespace gui {

class ButtonGroup;
/**
 * \ingroup coreGUI
 *
 * The GUI Button class.<br>
 * A Button is a GUI element that can be pressed by the mouse.<br>
 * An ActionListener can be attached to invoke a certain function.<br>
 * The button can be set to be a toggle element. That means, that one click
 * enables the button and another will disable it. An ActionEvent will 
 * be thrown after each click.
 *
 * \date 03-28-2007
 *
 * \author juckel
 * \author dennis
 * 
 */
class GUI_EXPORT Button : 
	public Label, 
	public IHighlightable,
	public ITextureAtlasUser
{
public:
	Button(void);
	/// Constructs a button with a specific aligned text
	Button(const std::string &text, eTextAlign align = CENTER);
	virtual ~Button(void);

	/// Enables toggle behavior
	void setToggleEnabled(bool value);
	
	/// Indicate if this is a toggle button
	const bool isToggleEnabled() const;

	// Toggle the button
	void setToggled(bool value); 

	// Indicate if this button is toggled
	const bool isToggled() const;

	// Draw function
	virtual void draw();

	/// Return the type of the gui element
	virtual inline const int getGUIType() const { return GUI_BUTTON; }

	/// The ButtonGroup can access the protected members
	friend class ButtonGroup;
protected:
	// Mouse functions for the button
	virtual void onMouseEntered(const MouseEvent &me);
	virtual void onMouseLeft(const MouseEvent &me);
	virtual void onMouseReleased(const MouseEvent &me);

	bool m_bIsToggleButton;		///< Is this a Toggle button
	bool m_bToggled;			///< Button toggled

	ButtonGroup *m_pGroup;
};

} // namespace

#endif
